<div class="page_title">
    <h2 class="fl">{$pageTitle}</h2>
    <a class="fr top_rt_btn iconfont iconfont-jia1" href="{:U('admin/Gift/gift_add')}">添加</a>
</div>
<section>
{notempty name="list.data"}
    <table class="table">
        <tr>
            <th>礼物编号</th>
            <th>礼物名称</th>
            <th>所需金币数量</th>
            <th>礼物展示图片</th>
            <th>礼物展示状态</th>
            <th>操作</th>
        </tr>
        {volist name="list.data" id="vo"}
        <tr>
            <td>{$vo.key}</td>
            <td>{$vo.value.name}</td>
            <td>{$vo.value.gold}</td>
            <td><img src="{:getImageUrl($vo.value.image,3)}" /></td>
            <td>
                <input type="checkbox" data-config_id="{:encrypt_id($vo.config_id)}" id="checkbox_video{$i}" class="chk_4 conf_status" {eq name='vo.status' value='1'}checked{/eq} />
                    <label for="checkbox_video{$i}">
                        <input type="hidden" value="{$vo.status}"  />
                    </label>
            </td>
            <td>
                <a href="JavaScript:void(0);"  data-key="{:encrypt_id($vo.config_id)}" class="inner_btn edit">编辑</a>
                <a href="JavaScript:void(0);"  data-key="{:encrypt_id($vo.config_id)}" class="inner_btn delete">删除</a>
            </td>
        </tr>
        {/volist}
    </table>
    <aside class="paging">
        {$list.html}
    </aside>
{else /}
<div class="not-data loadContent" data-href="{:U('admin/Gift/gift_add')}">添加礼物</div>
{/notempty}
</section>
<script>
$(function(){
    /** 点击开启或关闭 **/
    $(".conf_status").bind('click',function(){
        var status = $(this).is(":checked") ? 1 : 0;
        var config_id = $(this).data('config_id');
        var send_data = {
            url:U('admin/Config/saveStatus'),
            type:'POST',
            data:{
                status:status,
                config_id:config_id
            }
        }
        send_ajax(send_data,function(res){
            if(res.status){
                //msg_success(res.data.info);
                return true;
            }else{
                msg_error(res.message);
            }
        });
    });
    /** 点击删除 **/
    $(".delete").click(function(){
        var config_id = $(this).data('key');
        msg({
            yes:'删除',
            no:'取消',
            txt:'确认删除?',
        },'question').then(function() {
            var send_data = {
                url:U('admin/Config/delete'),
                data:{config_id:config_id},
                type:'POST',
            };
            send_ajax(send_data,function(response){
                if(response === false){
                    DEBUG && admin.log(ajax_error);
                    return false;
                }
                if(response.status == 1){
                    msg_success(response.data.info,'',1000);
                    setTimeout(function(){
                        //admin.getContentByUrl(response.data.jumpurl);
                        admin.getContentByUrl(admin.lastGetUrl);
                    },1000);
                }else{
                    msg_error(response.message);
                }
                admin.log(response);
            });
            
            
        }, function(miss) {
             //dismiss can be 'cancel', 'overlay', 'close', 'timer'
            //if (miss === 'cancel') {
                //msg('你取消了')
            //}
        });
    });
    /** 点击编辑 **/
    $(".edit").click(function(){
        var config_id = $(this).data('key');
        var url = U("admin/Gift/gift_edit")+'?config_id='+config_id;
        admin.getContentByUrl(url);
    });
});
</script>